package cn.zptc.springbootdemo.config;

import cn.zptc.springbootdemo.service.MyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ：zhaoweiwei
 * @date ：创建于 2025/3/3 14:36
 * @description：
 * @modified By：
 * @version: 1.0.0
 */
@Configuration
public class MyMVCConfig implements WebMvcConfigurer {

    @Autowired
    private MyInterceptor myInterceptor;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/backend/**").addResourceLocations("classpath:/backend/");
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/backend/toLoginPage").setViewName("/backend/login.html");
        registry.addViewController("/toDownloadPage").setViewName("download");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(myInterceptor).addPathPatterns("/**").excludePathPatterns("/backend/toLoginPage","/backend/login.html");
    }
}
